/**
 * @author zhangqiang
 * @date   17/7/20
 */
import React, {Component} from 'react'
import {connect} from 'react-redux'
import { bindActionCreators } from 'redux'
import {Toast} from 'antd-mobile'
import {Title} from '../../components/common'
import common from '../../utils/common'
import style from './index.scss'


class PassInformation extends Component {
	constructor(props) {
		super(props);
		this.state={}
		this.type=this.props.params.type
	}

	toUrl(url) {
      this.context.router.push(url);
  	}

	componentWillMount(){

	}

	componentDidMount() {
		common.setViewTitle('通行证信息');
	}
	render() {
  		let cacheRes = JSON.parse(sessionStorage.getItem('twPassCache'));//首页缓存  订单确认页缓存
		let fmtAll = 'yyyy-MM-dd';
		let birthday=common.format(cacheRes.birthday,fmtAll);
		let validateEnd=common.format(cacheRes.validateEnd,fmtAll);
		let createTime=common.format(cacheRes.createTime,fmtAll);

		return (
			<div className={style.passInformation}>
				<div>
					<Title text="申请人证件信息" inLine={false} bgColor='#f2f2f2'/>
					<div className={style.passBox+' '+'cf'}>
						<p className={style.msg}>
							<span>申&nbsp;&nbsp;请&nbsp;人:</span>
							<span>{cacheRes.passName}</span>
						</p>
						<p className={style.msg}>
							<span>通行证号:</span>
							{
								this.type=='enCode'?
									<span>{cacheRes.passCode.substr(0,3)+'****'+cacheRes.passCode.substr(cacheRes.passCode.length-2,cacheRes.passCode.length)}</span>:
									<span>{cacheRes.passCode}</span>
							}
						</p>
						<p className={style.msg}>
							<span>出生日期:</span>
							<span>{birthday}</span>
						</p>
						<p className={style.msg}>
							<span>有效期至:</span>
							<span>{validateEnd}</span>
						</p>
						{
							cacheRes.birthPlace&&cacheRes.type!=5?
								<p className={style.msg}>
									<span>户&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;籍:</span>
									<span className='text-overflow-one' style={{width: '5.3rem',textAlign: 'right'}}>{cacheRes.birthPlace.replace(null,'')}</span>
								</p>:''
						}

					</div>
				</div>

			<div>
				<Title text="签注信息" inLine={false} bgColor='#f2f2f2'/>
				<div className={style.passBox+' '+'cf'}>
					<p className={style.msg}>
						<span>签注类别:</span>
						<span>{cacheRes.typeName}</span>
					</p>
					<p className={style.msg}>
						<span>签注发票:</span>
						<span>{cacheRes.needInvoice==0?'不需要':'需要'}</span>
					</p>
					<p className={style.msg}>
						<span>签注种类:</span>
						<span>六月一次</span>
						{/* <span>{cacheRes.timesName}</span> */}
					</p>
				</div>
			</div>

			<div style={{height:'.5rem'}}></div>
			</div>
		)
    }
}

//使用context
PassInformation.contextTypes = {
    router: React.PropTypes.object.isRequired
};

PassInformation.defaultProps = {

};


export default connect()(PassInformation);
